/*
 * @Author: sjf 1758142861@qq.com
 * @Date: 2023-03-16 17:49:32
 * @LastEditors: sjf 1758142861@qq.com
 * @LastEditTime: 2023-03-22 15:25:59
 * @FilePath: /D_C_lib/lw_process/day2/mythread.cc
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
//表示的是创建一批线程的引路写法
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cassert>
#include<unistd.h>
#include<pthread.h>

using namespace std;

void* start_routine(void* args)
{
    const char* name = static_cast<const char*>(args);
    std::cout << "i am new pthread name:" << name << std::endl;
    sleep(1);
}

int main()
{
    vector<pthread_t> tids;
#define NUM 10
    for(int i = 0; i < NUM; i++)
    {
        pthread_t tid;
        char buffer[64];
        snprintf(buffer,sizeof(buffer),"%s:%d","thread",(void*)buffer,i);
        //pthread_create(&tid,nullptr,start_routine,(void*)"thread one");
        pthread_create(&tid,nullptr,start_routine,buffer);
    }
    while(true)
    {
        std::cout << "new thread create succes,name: main thread" << std::endl;
        sleep(1);
    }
    return 0;
}